import {createInstance} from "../createInstance.js";

const instance = createInstance('company');

// 创建一个公司
export const createCompany = async (id, name) => {
    return instance.post('/createCompany', {id, name});
};

// 获取公司管理员
export const getCompanyAdmin = async (id, companyId) => {
    return instance.post('/getCompanyAdmin', {id, companyId});
};

// 设置公司管理员
export const addCompanyAdmin = async (id, companyId, userId) => {
    return instance.post('/addCompanyAdmin', {id, companyId, userId});
};

// 删除公司管理员
export const removeCompanyAdmin = async (id, companyId, userId) => {
    return instance.post('/removeCompanyAdmin', {id, companyId, userId});
};

// 获取公司员工列表
export const getCompanyUserList = async (id, companyId) => {
    return instance.post('/getCompanyUserList', {id, companyId});
};

// 添加公司员工
export const addCompanyUser = async (id, companyId, userId) => {
    return instance.post('/addCompanyUser', {id, companyId, userId});
};
// 添加公司员工
export const addCompanyUserByNameOrEmailOrMobile = async (id, companyId, username, email, mobile) => {
    return instance.post('/addCompanyUserByNameOrEmailOrMobile', {id, companyId, username, email, mobile});
};

// 删除公司员工
export const deleteCompanyUser = async (id, companyId, userId) => {
    return instance.post('/deleteCompanyUser', {id, companyId, userId});
};

// 获取公司某一账单历史记录
export const getCompanyBillHistory = async (id, companyId, billId) => {
    return instance.post('/getCompanyBillHistory', {id, companyId, billId});
};

// 添加公司账单
export const addCompanyBill = async (id, companyId, category, remark, amount, isComplete, billTime) => {
    return instance.post('/addCompanyBill', {id, companyId, category, remark, amount, isComplete, billTime});
};

// 获取公司账单
export const getCompanyBills = async (id, companyId) => {
    return instance.post('/getCompanyBills', {id, companyId});
};

// 修改公司账单
export const updateCompanyBill = async (id, companyId, billId, category, remark, amount, isComplete, billTime) => {
    return instance.post('/updateCompanyBill', {id, companyId, billId, category, remark, amount, isComplete, billTime});
};

// 删除公司账单
export const deleteCompanyBill = async (id, companyId, billId) => {
    return instance.post('/deleteCompanyBill', {id, companyId, billId});
};

// 获取公司账单类型
export const getCompanyBillCategory = async (id, companyId) => {
    return instance.post('/getCompanyBillCategory', {id, companyId});
};

// 添加公司账单类型
export const addCompanyBillCategory = async (id, companyId, name, is_out) => {
    return instance.post('/addCompanyBillCategory', {id, companyId, name, is_out});
};

// 删除公司账单类型
export const deleteCompanyBillCategory = async (id, companyId, categoryId) => {
    return instance.post('/deleteCompanyBillCategory', {id, companyId, categoryId});
};

// 创建仓库品类
export const depotGoodsCreate = async (id, companyId, name, unit, cost, amount, rawMaterial) => {
    return instance.post('/depotGoodsCreate', {id, companyId, name, unit, cost, amount, rawMaterial});
};

// 仓库物品入库
export const depotGoodsIn = async (id, companyId, goodsId, amount, remark) => {
    return instance.post('/depotGoodsIn', {id, companyId, goodsId, amount, remark});
};

// 仓库物品出库
export const depotGoodsOut = async (id, companyId, goodsId, amount, remark) => {
    return instance.post('/depotGoodsOut', {id, companyId, goodsId, amount, remark});
};

// 删除仓库物品
export const depotGoodsDelete = async (id, companyId, goodsId) => {
    return instance.post('/depotGoodsDelete', {id, companyId, goodsId});
};

// 查询仓库库存
export const getDepotGoods = async (id, companyId) => {
    return instance.post('/getDepotGoods', {id, companyId});
};

// 查询仓库物品的记录
export const getDepotRecord = async (id, companyId, goodsId) => {
    return instance.post('/getDepotRecord', {id, companyId, goodsId});
};

// 获取公司的所有仓库记录
export const getDepotAllRecord = async (id, companyId) => {
    return instance.post('/getDepotAllRecord', {id, companyId});
};
